/**
 * OperationLogDaoImpl.java
 * Created at 2017-07-13
 * Created by Jackie liu
 * Copyright (C) 2014, All rights reserved.
 */
package com.huabo.dao.impl.postgresql;

import com.huabo.base.BaseDaoImpl;
import com.huabo.dao.inter.OperationLogDao;
import com.huabo.model.OperationLog;
import com.huabo.sql.builder.WhereBuilder;
import com.huabo.utils.Page;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;

import java.util.Map;

/**
 * <p>ClassName: OperationLogDaoImpl</p>
 * <p>Description: 通用操作日志Dao实现</p>
 * <p>Author: Jackie liu</p>
 * <p>Date: 2017-07-13</p>
 */
@Repository
public class OperationLogDaoImpl extends BaseDaoImpl<OperationLog, Long> implements OperationLogDao {

	@Override
	public Page<OperationLog> queryPage(Map<String, Object> params) {
		WhereBuilder wb = new WhereBuilder();
		wb.setOrderBy("F_OPERATE_TIME DESC");
		if (params != null && params.size() > 0) {
			wb.andFullLike("F_USER_NAME", params.get("name"));
			initPageParam(wb, params);

			String searchInput = (String) params.get("searchInput");
			if (StringUtils.isNotEmpty(searchInput)) {
				wb.andGroup().andFullLike("F_FUNCTION_NAME", searchInput)
						.orFullLike("F_RESOURCE_NAME", searchInput).orFullLike("_USER_NAME", searchInput);
			}
		}
		Page<OperationLog> queryPage = queryPage(wb);
		return queryPage;
	}
}